// 表单接口
export interface rowForm {
  show: boolean;
  pid?: number[];
  type?: number;
  permission?: permission[];
  name?: string;
  component?: string;
  path?: string;
  redirect?: string;
  metaItem?: meta;
}

export interface meta {
  icon?: string;
  title?: string;
  frameSrc?: string;
  keepAlive?: boolean;
  showLink?: boolean;
}

export interface permission {
  label: string;
  value: string;
}

// 表单默认值
export function getRowForm(): rowForm {
  return {
    show: false,
    pid: [0],
    type: 1,
    component: "Layout",
    metaItem: {
      title: undefined,
      icon: "IF-icon-yingyong-moren" // 默认图标
    }
  };
}
// 错误消息提示
export interface ErrMsg {
  pid?: string;
  type?: string;
  permission?: string;
  name?: string;
  component?: string;
  path?: string;
  redirect?: string;
  icon?: string;
  title?: string;
  frameSrc?: string;
  keepAlive?: string;
  showLink?: string;
}

export const defaultErrMsg = {
  pid: "",
  type: "",
  permission: "",
  name: "",
  component: "",
  path: "",
  redirect: "",
  icon: "",
  title: "",
  frameSrc: "",
  keepAlive: "",
  showLink: ""
};

/**
 * 默认的模块类型
 */
export const defaultModuleTypes = [
  { label: "模块", value: 1 },
  { label: "页面", value: 2 }
];

// 定义验证规则
export const formRules = {
  metaItem: {
    title: [
      { required: true, message: "请输入菜单名称", trigger: "blur" },
      { min: 2, max: 8, message: "菜单名称长度为2到8个字符", trigger: "blur" }
    ]
  },
  name: [{ required: true, message: "请输入组件名称", trigger: "blur" }],
  path: [{ required: true, message: "请输入访问路径", trigger: "blur" }]
};

// 默认的模块选项
export const defaultModuleOpts = [{ label: "顶级模块", value: 0 }];
